Skip to content

tasker: Ava Activity state plugin#65

Merged
brownard merged 1 commit intobrownard:masterfrom
xvello:tasker
Mar 21, 2026
Merged

tasker: Ava Activity state plugin#65
brownard merged 1 commit intobrownard:masterfrom
xvello:tasker

Conversation

@xvello
Copy link
Copy Markdown
Contributor

@xvello xvello commented Mar 9, 2026

This PR adds a first Tasker state plugin, following the doc at https://tasker.joaoapps.com/pluginslibrary.html. Instead of one-big-plugin-per-application, Tasker uses small runners focussed on one thing:

  • one state condition: tasks can be executed when entering (and leaving) that state. That's the best fit for my "turn screen on" use case: the state is kept active while timers runs, and turned off when timers end
  • one event type: something happens, but the state is not tracked. We could use it to export the latest EspHomeState for finer-grained automation cases
  • one action: tasker calls to the app. For example, we could trigger listening without a wake word, or stop ringing

I updated #49 with these possible use cases as the tracking issue.

Some notes:

  • Plugins are called through reflexion and Java calls to a singleton, which requires global state. This is why we're copying the state into a companion object
  • AvaActivityInput could be extended in the future, for example with a finer grained EspHomeState selection. I went with a less granular "Conversing` option right now, because it's easier to setup and gives us more latitude to modify the app's internals without breaking automations
  • I didn't add a "enable Tasker integration" option because I assume that the cost (copying a couple of pointers and sending an intent) is negligible and I'm afraid that people might miss the option and open issues. Happy to add one though.
  • Starting a dedicated TASKER.md documentation file for discoverability and because this file will probably grow to a half-dozen plugins
  • State plugins can return a struct with info instead of Unit, so my first iteration returned the value of EspHomeState and the number of timers, but these are a footgun I decided to remove: they are accessible to create conditions on, but these conditions are NOT re-evaluated when the fields changes, only when the state is initially satisfied

@xvello xvello changed the title Tasker integration First Tasker plugin Mar 10, 2026
@xvello xvello changed the title First Tasker plugin tasker: first plugin: Ava Activity state Mar 10, 2026
@xvello xvello changed the title tasker: first plugin: Ava Activity state tasker: Ava Activity state plugin Mar 10, 2026
@xvello xvello marked this pull request as ready for review March 10, 2026 12:52
@xvello xvello mentioned this pull request Mar 10, 2026
4 tasks
@xvello
Copy link
Copy Markdown
Contributor Author

xvello commented Mar 11, 2026

@brownard I also implemented two tasker actions (and their unit tests) in this branch that stacks on top of this PR. Would you prefer I keep it as a separate PR for later, or push that commit in this PR?

Unit-testing that state condition plugin proved tricky, because of the need to inject a Context

@brownard
Copy link
Copy Markdown
Owner

I'm good with this in principle but want to take a bit of care to keep the Tasker stuff as loosely coupled as possible. I'm particularly thinking about the follow on commit that adds a direct dependency in the voice satellite.

I intend to refactor the ESPHome implementation slightly to make the voice satellite a component of an ESPHome device, rather than inheriting from it, which should simplify its dependencies, in the process I can add public methods for wake/stop timer/etc which will hopefully mean the Tasker plugin can call those directly without it needing to be internal to the satellite.

I'll install Tasker and have a play around.

@xvello
Copy link
Copy Markdown
Contributor Author

xvello commented Mar 11, 2026

Cool! I wired up the Wake Satellite action on the bixby button, which helps a lot with testing (I don't wake up the other satellites accidentally 😅). Set the bixby button to open the camera: Tasker ships a helper app that fulfills the camera intent and triggers a Tasker event.

For actions, I specifically went with simple callback functions to give us flexibility in refactoring the underlying code: we can easily register them from VoiceSatelliteService once the associated methods are exposed there. I didn't do it in my PR to reduce the diff size, but I could make wakeSatellite and stopTimer public if you prefer.

I'm curious about your advice on unit testing. The two actions were easy to unit test by copying from SatelliteTest.kt, but to test the state plugin we need to run VoiceSatelliteService into an Android Context. requestQuery requires a valid context (it's emitting an Intent, to trigger a pull from Tasker).

@brownard
Copy link
Copy Markdown
Owner

I have a plan for the refactoring so I will try and get that done first.

Regarding the testing you can add an instrumentation test in the androidTest source, like I've done for wake word testing here. These run on your connected device/emulator so give you access to a context, etc, but are obviously a bit slower, and are not currently run on Github.

@brownard brownard merged commit 0ed1d91 into brownard:master Mar 21, 2026
1 check passed
@brownard
Copy link
Copy Markdown
Owner

Thanks for this, I have merged it in as is. I will refactor the voice satellite/device in a later pull request but feel free to open further pull requests with additional actions/conditions and I will work around them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants